package com.demo.security.config;

import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class PermissionChecker {
    private SecurityRoleConfig securityRoleConfig;

    public PermissionChecker(SecurityRoleConfig securityRolesConfig) {
        this.securityRoleConfig = securityRolesConfig;
    }

    public boolean hasPermission(String role, String permission) {
        Map<String, List<String>> roles = securityRoleConfig.getRoles();
        List<String> permissions = roles.get(role);
        return permissions != null && permissions.contains(permission);
    }
}
